package com.server.pojo;

import com.server.pojo.base.PojoBase;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.Hibernate;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import java.util.Objects;

@Getter
@Setter
@ToString

@Entity
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Table
public class MobileAppAlarm extends PojoBase {

    @ManyToOne
    MobileApp mobileApp;

    @ManyToOne
    Alarm alarm;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        MobileAppAlarm that = (MobileAppAlarm) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
